<?php
/*
//传统的做法如下：直接在主体类中添加逻辑
class Event{
    function trigger(){
        //原来的事件
        echo 'Event<br />';

        //update
        echo '新增逻辑1<br />';
        echo '新增逻辑2<br />';
        echo '新增逻辑3<br />';
    }
}

$event = new Event();
$event->trigger();
*/
spl_autoload_register();
class Event extends \vendor\EventGenerator
{
    function trigger(){
        //原来的事件
        echo 'Event<br />';

        //update
        $this->notify();
    }
}

class Observer1 implements \vendor\Observer
{
    function update($event_info = null){
        echo '新增逻辑1<br />';
    }
}
class Observer2 implements \vendor\Observer
{
    function update($event_info = null){
        echo '新增逻辑2<br />';
    }
}

$event = new Event();
$event->addObserver(new Observer1());
$event->addObserver(new Observer2());
$event->trigger();